import 'package:json_annotation/json_annotation.dart';

part 'coupon.g.dart';

@JsonSerializable()
class Coupon extends Object {
  @JsonKey(name: 'advanceNoticeDays')
  int advanceNoticeDays;

  @JsonKey(name: 'beginTime')
  String beginTime;

  @JsonKey(name: 'couponDiscountAmount')
  int couponDiscountAmount;

  @JsonKey(name: 'couponName')
  String couponName;

  @JsonKey(name: 'couponReceivedNum')
  int couponReceivedNum;

  int get couponSurplusNum => couponTotalNum - couponReceivedNum;

  @JsonKey(name: 'couponTotalNum')
  int couponTotalNum;

  @JsonKey(name: 'couponType')
  String couponType;

  @JsonKey(name: 'creator')
  int creator;

  @JsonKey(name: 'ctime')
  String ctime;

  @JsonKey(name: 'endTime')
  String endTime;

  @JsonKey(name: 'id')
  int id;

  @JsonKey(name: 'personLimitNum')
  int personLimitNum;

  @JsonKey(name: 'relativeDays')
  int relativeDays;

  @JsonKey(name: 'shareImageUrl')
  String shareImageUrl;

  @JsonKey(name: 'shareTitle')
  String shareTitle;

  @JsonKey(name: 'storeId')
  int storeId;

  @JsonKey(name: 'timeLimitType')
  String timeLimitType;

  @JsonKey(name: 'updater')
  int updater;

  @JsonKey(name: 'userShareBonus')
  int userShareBonus;

  @JsonKey(name: 'usingRange')
  String usingRange;

  @JsonKey(name: 'usingStatus')
  String usingStatus;

  @JsonKey(name: 'usingThreshold')
  int usingThreshold;

  @JsonKey(name: 'utime')
  String utime;

  @JsonKey(name: 'waiterShareBonus')
  int waiterShareBonus;

  String couponDescribe;

  //现金券
  static const String TYPE_CASH = 'cash';

  //折扣券
  static const String TYPE_DISCOUNT = 'discount';

  //外卖
  static const String USE_RANGE_TAKEOUT = 'takeout';

  //堂食
  static const String USE_RANGE_DINNER = 'dinner';

  //电商
  static const String USE_RANGE_SHOP = 'shop';

  //绝对时间
  static const String TIME_ABSOLUTELY = 'absolutely';

  //相对今天
  static const String TIME_TODAY = 'today';

  //相对明天
  static const String TIME_TOMORROW = 'tomorrow';

  //启用
  static const String STATUS_ON = 'on';

  //不启用
  static const String STATUS_OFF = 'off';

  Coupon();

  factory Coupon.fromJson(Map<String, dynamic> srcJson) => _$CouponFromJson(srcJson);

  Map<String, dynamic> toJson() => _$CouponToJson(this);
}
